package com.dance.sharevalidator.controller;

import com.dance.sharevalidator.entity.Emp;
import com.dance.sharevalidator.service.IEmpService;
import com.dance.sharevalidator.validation.ValidList;
import com.dance.sharevalidator.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.groups.Default;
import java.util.List;

@RestController
@RequestMapping("/emp")
@Validated
public class EmpController {

    @Autowired
    private IEmpService empService;

    @PostMapping
    public ResultVo<Object> add(@RequestBody @Validated({Emp.Add.class, Default.class}) Emp emp) {
//        empService.add(emp);
        return ResultVo.success();
    }

    @PostMapping("/addList")
    public ResultVo<Object> addList(@RequestBody @ValidList( groupings = {Emp.Add.class, Default.class}, quickFail = true) List<Emp> empList) {
        return ResultVo.success();
    }

    @PutMapping
    public ResultVo<Object> update(@RequestBody @Validated({Emp.Update.class, Default.class}) Emp emp) {
        return ResultVo.success();
    }

    @PutMapping("/update")
    public ResultVo<Object> update2(@RequestBody @Valid Emp emp) {
        return ResultVo.success();
    }

}
